module Lark
  module Apis
    module Calendar
      def get_calendar(calendar_id:)
        get "calendar/v4/calendars/#{calendar_id}"
      end

      def get_calendars(page_size: nil, page_token: nil, sync_token: nil)
        get 'calendar/v4/calendars', params:{
          page_size: page_size,
          page_token: page_token,
          sync_token: sync_token
      }.compact
      end

      def get_schedule(calendar_id:,enent_id:)
        get "calendar/v4/calendars/#{calendar_id}/events/#{event_id}"
      end

      def get_schedule(calendar_id:)
        get "calendar/v4/calendars/#{calendar_id}/events"
      end

      def create_schedule(calendar_id, payload)
        post "calendar/v4/calendars/#{calendar_id}/events", payload
      end


      def create_schedule_attendees(calendar_id, event_id, payload)
        post "calendar/v4/calendars/#{calendar_id}/events/#{event_id}/attendees", payload
      end
      
      # search calendar
      def search_calendar(page_token: nil, page_size: nil, query:)
        post "calendar/v4/calendars/search", params: { 
          page_token: page_token, 
          page_size: page_size
      }.compact,
      query: query
      end

      # subscribe calendar
      def subscribe_calendar(calendar_id:)
        post "calendar/v4/calendars/#{calendar_id}/subscribe"
      end

    end
  end
end